﻿/********************************************************
 * 类名： VendorCategoryDAL.cs
 * 功能： 供应商业务层
 *   ver	变更日		作者			变更内容
 * ────────────────────────────────────────
 *   V01.0	2013-11-27	李波			初版
 *
 * Copyright (c) 2013，李波版权所有
 ********************************************************/
using System;
using System.Collections;
using PSS.DAL.SetManage.AuxiliaryInfo;
using PSS.Entity;
using PSS.Entity.SetManage.AuxiliaryInfo;
using PSS.Utility;

namespace PSS.BLL.SetManage.AuxiliaryInfo
{
    public class VendorCategoryBLL
    {
        private readonly VendorCategoryDAL _dal = new VendorCategoryDAL();
        public string GetVendorCategoryList(Pagination qcmodel)
        {
            var total = _dal.GetTotal();
            var list = _dal.GetVendorCategoryList(qcmodel);
            return JsonHelper.Encode(total, list);
        }
        public string GetVendorCategoryListByCombobox()
        {
            return JsonHelper.Encode(_dal.GetVendorCategoryListByCombobox());
        }
        public bool ModifyVendorCategory(string data)
        {
            var model = new VendorCategoryEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.VCategoryId = new Guid(row["VCategoryId"].ToString());
                model.VCategoryName = row["VCategoryName"].ToString();
            }
            return _dal.ModifyVendorCategory(model);
        }
        public bool AddVendorCategory(string data)
        {
            var model = new VendorCategoryEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.VCategoryId = Guid.NewGuid();
                model.VCategoryName = row["VCategoryName"].ToString();
            }
            return _dal.AddVendorCategory(model);
        }
        public string GetVendorCategoryInfo(string id)
        {
            return JsonHelper.Encode(_dal.GetVendorCategoryInfo(id));
        }
        public bool RemoveVendorCategory(string id)
        {
            return _dal.RemoveVendorCategory(id);
        }
    }
}
